//上网套餐类
public class NetworkPackage extends AbstractPackage implements NetworkService {

    public NetworkPackage(int monthlyCost, int phonePackage) {

        super(monthlyCost,phonePackage);                          // 继承抽象类套餐
    }
    //重写抽象套餐类，打印套餐信息
    @Override

    public void showInfo() {
        System.out.println("上网套餐：流量包"+getPhonePackage()+"GB;每月资费"+getMonthlyCost()+"元/GB");
    }

    // 重写上网服务接口方法

    @Override
    public void server(int networkData, PhoneCard phoneCard) {

        int consumeValue = networkData * getMonthlyCost();                                    // 消费金额=上网流量*资费

        phoneCard.setAccountBalance(phoneCard.getAccountBalance() - consumeValue);            // 手机余额减消费

        phoneCard.addConsume(consumeValue, 0, networkData);               // 添加流量消费数量

        phoneCard.showInfo();                                                                // 打印手机卡当前消费信息
    }

}
